package Operator;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class ReturnOperator implements IOPerator{

    @Override
    public void work(BookList bookList) {
        System.out.println("归还图书");
        System.out.println("请输入你要归还的图书的名字");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        int bookcount = bookList.getListsize();
        for (int i = 0; i < bookcount; i++) {
            Book book = bookList.get_book(i);
            if(book.getName().equals(name)){
                book.setBorrow(false);
                System.out.println("归还成功");
                return;
            }
        }
        System.out.println("没有这本书");
    }
}
